home *** CD-ROM | disk | FTP | other *** search
- Path: keats.ugrad.cs.ubc.ca!not-for-mail
- From: c2a192@ugrad.cs.ubc.ca (Kazimir Kylheku)
- Newsgroups: comp.lang.c
- Subject: Re: PUBLIC / PRIVATE
- Date: 17 Apr 1996 19:07:54 -0700
- Organization: Computer Science, University of B.C., Vancouver, B.C., Canada
- Message-ID: <4l485qINN14r@keats.ugrad.cs.ubc.ca>
- References: <4l3k8d$hkp@mulga.cs.mu.OZ.AU>
- NNTP-Posting-Host: keats.ugrad.cs.ubc.ca
-
- In article <4l3k8d$hkp@mulga.cs.mu.OZ.AU>,
- Falchion <simc@mundil.cs.mu.OZ.AU> wrote:
- >I'm analysing some C source code and I've
- >come across PUBLIC and PRIVATE keywords
- >
- >eg PUBLIC char * app_name = "Lynx";
- >
- > PRIVATE void HTFWriter_write ARGS3(HTSteam, *, me, CONST char*,
- > s, int, l) { fwrite(s, 1, l, me->fp) }
- >
- >
- >I though C didn't have PUBLIC or PRIVATE ?
-
- Ha ha. They are just #define symbols. The ARGS3, and their upper case should
- have put you onto this: C would never have keywords that are all caps. Heck, we
- would look like we are shouting at the compiler!
-
- The Linux kernel uses a similar scheme. For debugging purposes, you name your
- static variables Static. This makes them external in fact when you are
- debugging, but evaluates to the actual "static" keyword when you make a
- production build. The whole purpose is to make symbols that are normally
- private to a module externally visible for debugging purposes, in that case.
- Most likely, PUBLIC just expands to nothing, and PRIVATE to "static".
-
- >It definitely doesn't look like C++ source code - it looks like
- >C code with PUBLIC and PRIVATE keywords scattered everywhere.
- >
- >2nd question:
- > PRIVATE void HTFWriter_write ARGS3(HTSteam, *, me, CONST char*,
- > s, int, l) { fwrite(s, 1, l, me->fp) }
- >
- > What is the ARGS3 ?
-
- It is another preprocessor macro. The idea here is probably to support
- old-style C compilers. If you have old-style C, ARGS3(HtSteam, ...) will
- probably evalute to an old-style declaration. In ANSI environments, it will
- expand into a new-style declaration.
-
- The above mechanism will fail miserably for function pointers, in which the
- declarator identifier cannot be so neatly disentangled from the rest of the
- declaration.
-
- This looks very familiar. The CERN HTTPD server has almost exactly the same
- kind of macro.
-
- > I'm accustomed to
- > return_type function_name(args) { ... }
-
- Pre-processor tricks can make a C program look like it is in another language.
- That's parly why upper-case is used for macro names---it's a warning sign that
- something weird is happening.
-